/*
 * @Author: szx
 * @Date: 2022-03-02 14:38:56
 * @LastEditTime: 2022-03-02 14:54:50
 * @Description:
 * @FilePath: \leetcode\1-99\94\94_2.js
 */
function TreeNode(val, left, right) {
    this.val = val === undefined ? 0 : val;
    this.left = left === undefined ? null : left;
    this.right = right === undefined ? null : right;
}

/**
 * @param {TreeNode} root
 * @return {number[]}
 */
 var inorderTraversal = function (root) {
    if (!root) return [];
    const st = [];
    const res = [];
    let node = root;
    while (st.length||node) {
        while (node) {
            st.push(node);
            node =node.left;
        }
        node = st.pop();
        res.push(node.val)
        node = node.right;
    }
    return res;
};
